﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using wpf.Utils;
using static wpf.ViewModel.MainWindowViewModel;

namespace wpf.ViewModel
{
    public class Locator
    {
        public static IServiceProvider ServiceProvide { get; set; } = null!;

        public Locator()
        {
            ServiceProvide = GetService();
        }
        private IServiceProvider GetService()
        {
            var service = new ServiceCollection();
            service.AddSingleton<MainWindowViewModel>();

            service.AddSingleton<LPlugin>();

            return service.BuildServiceProvider();
        }
        public MainWindowViewModel MainWindowViewModel
        {
            get
            {
                return ServiceProvide.GetService<MainWindowViewModel>()!;
            }
        }

        public LPlugin LPlugin
        {
            get
            {
                return ServiceProvide.GetService<LPlugin>()!;
            }
        }

    }
}
